package com.edu.app.config;

import com.edu.app.service.sys.plupload.PluploadService;
import com.edu.app.util.alioss.OssAccessor;
import com.edu.app.util.alioss.OssConfig;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AliOssConfiguration {

    @Bean(initMethod="init",destroyMethod="destroy")
    public OssAccessor getOssFileUploaderBean() {
        OssAccessor ossAccessor =  new OssAccessor();
        ossAccessor.setAccessKeyId(OssConfig.EDUCRM_AccessKeyId);
        ossAccessor.setAccessKeySecret(OssConfig.EDUCRM_AccessKeySecret);
        ossAccessor.setOssBucket(OssConfig.bucket);
        ossAccessor.setOssEndpoint(OssConfig.endpoint);
        ossAccessor.setTimeout(5000);

        return ossAccessor;
    }


    @Bean
    public PluploadService getPluploaderBean() {
        PluploadService pluploadService =  new PluploadService();
        return pluploadService;
    }
}
